package com.devilvan.betrice.aiqicha.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.devilvan.betrice.aiqicha.dto.AiqichaOpenNoticeDto;
import com.devilvan.betrice.aiqicha.po.AiqichaOpenNoticePo;
import com.devilvan.betrice.aiqicha.service.AiqichaOpenNoticeService;
import com.devilvan.betrice.aiqicha.mapper.AiqichaOpenNoticeMapper;
import com.devilvan.betrice.aiqicha.repository.AiqichaOpenNoticeRepository;
import org.springframework.stereotype.Service;
import com.devilvan.betrice.util.UCopy;

import javax.annotation.Resource;
import java.util.List;

/**
* @author Evad.Wu
* @Description 爱企查-开庭公告信息 业务逻辑类
* @date 2022-09-24
*/
@Service
public class AiqichaOpenNoticeServiceImpl extends ServiceImpl<AiqichaOpenNoticeMapper, AiqichaOpenNoticePo> implements AiqichaOpenNoticeService {
    @Resource(name = "aiqichaOpenNoticeRepository")
    private AiqichaOpenNoticeRepository aiqichaOpenNoticeRepository;

    @Override
    public AiqichaOpenNoticePo saveUpdate(AiqichaOpenNoticeDto aiqichaOpenNoticeDto) {
        AiqichaOpenNoticePo aiqichaOpenNoticePo = new AiqichaOpenNoticePo();
        UCopy.fullCopy(aiqichaOpenNoticeDto, aiqichaOpenNoticePo);
        return aiqichaOpenNoticeRepository.saveAndFlush(aiqichaOpenNoticePo);
    }

    @Override
    public List<AiqichaOpenNoticePo> saveUpdateBatch(List<AiqichaOpenNoticeDto> list) {
        List<AiqichaOpenNoticePo> aiqichaOpenNoticePoList = UCopy.fullCopyCollections(list, AiqichaOpenNoticePo.class);
        return aiqichaOpenNoticeRepository.saveAllAndFlush(aiqichaOpenNoticePoList);
    }
}
